import api from '@/services'
const state = {
    projectData: [],
    types: [],
    tag: [],
    haveData:false,       // 是否有新增数据
    newTableData: [],     // 新增的表格数据
    showNewData: false,   // 表格是否显示新增的数据
}

const mutations = {
    initProjectData(state, projectData) {
        state.projectData = projectData
    },
    setTypes(state, types) {
        state.types = types
    },
    setTag(state, tag) {
        state.tag = tag
    },
    setNewTableData(state, newTableData) {
        state.newTableData = newTableData;
        state.haveData = true;
    },
    setShowNewData(state, showNewData) {
        state.showNewData = showNewData
        console.log(showNewData);
    },
}

const actions = {
    async initProject(context) {
        let projectData = await api.projectMessage.pagination(1, 2).then(res => res.data)
        context.commit('initProjectData', projectData)

    },
    async initTag(context) {
        // 获取项目标记
        let tag = await api.navData.getTag().then(res => res.data);
        context.commit('setTag', tag)
    },
    async initType(context) {
        // 获取项目类型 
        let types = await api.navData.getType().then(res => res.data)
        context.commit('setTypes', types)
    }

}

export default {
    state,
    actions,
    mutations,
}